package cn.tjnext.apply.dao;

import cn.tjnext.apply.entity.AbstractEntity;
import cn.tjnext.apply.entity.UserEntity;
import cn.tjnext.apply.repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

/**
 * Created by cp on 2017/7/31.
 */
@Component
public class UserDao extends AbstractEntityDao<UserEntity, UserRepository> {

    @Autowired
    private UserRepository userRepository;

    @Override
    protected UserRepository getRepository() {
        return userRepository;
    }

    @Override
    public Sort getDefaultSorting() {
        return UserEntity.DEFAULT_SORTING;
    }

    @Override
    public <T extends AbstractEntity> Page<T> searchByKeyword(String keyWord, Pageable pageable) {
        return null;
    }

    /**
     * 根据手机号查找注册用户
     * @param data
     * @return
     */
    public UserEntity findByPhone(String data) {
        UserEntity userEntity = userRepository.findByPhone(data);
        return userRepository.findByPhone(data);
    }
}
